/**
 * @file clieent.cpp
 * @author luxian (you@domain.com)
 * @brief 这里是winsock的实例代码 upd的客户端 / 接收方 
 *  运行时需要先运动接收方再启动发送方
 * @version 0.1
 * @date 2022-03-02
 * 
 * @copyright Copyright (c) 2022
 * 
 */
#include<winsock2.h>
#include<IOSTREAM>
#pragma comment(lib,"ws2_32.lib")
using namespace std;

int main (){
    //  W
    WSADATA wsadata;
    WSAStartup(MAKEWORD(2,2),&wsadata);
    SOCKET clientsocket = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
    //绑定套接字
    sockaddr_in socketaddr ;
    //保存其他信息
    ZeroMemory(&socketaddr,sizeof(socketaddr));
    socketaddr.sin_family= PF_INET;
    socketaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
    socketaddr.sin_port = htons (1234);


    connect(clientsocket,(SOCKADDR *)&socketaddr,sizeof(socketaddr));
    //接受服务器发送信息
    char  recieve[512]= {0};
    recv(clientsocket, recieve,512,0);
    cout<<"Message from Server： "<<recieve<<endl;
    closesocket(clientsocket);

    //tingzhi dll
    WSACleanup();
    cin.get();
    cin.get();
    return 0;

}